package com.bana.fvs.protocol;

import com.bana.fvs.model.FogArea;

public class NoticeRoadStatus0A {
    public int getId()
    {
        return 0x0A;
    }

    public FogArea toModel(byte[] buffer) {

        FogArea road=new FogArea();
        road.setJcybsm(buffer[1]);

        byte[] ascBuffer=new byte[buffer.length-4];
        System.arraycopy(buffer,3,ascBuffer,0,ascBuffer.length);

        String s=new String(ascBuffer);
        String[] datas=s.split("\\s+");
        if(datas.length>=11)
        {
            //路面状态
            if(datas[2].length()==3)
            {
                char c=datas[2].charAt(2);
                if(c=='0')
                {
                    road.setLmztdm(10);
                }
                else if(c=='1')
                {
                    road.setLmztdm(11);
                }
                else if(c=='2')
                {
                    road.setLmztdm(12);
                }
                else if(c=='3')
                {
                    road.setLmztdm(13);
                }
                else if(c=='6')
                {
                    road.setLmztdm(16);
                }
                else if(c=='7')
                {
                    road.setLmztdm(17);
                }
                else if(c=='9')
                {
                    road.setLmztdm(19);
                }
                else
                {
                    road.setLmztdm(20);
                }
            }
            else
            {
                road.setLmztdm(20);
            }

            //湿滑指数
            road.setShxs(Float.parseFloat(datas[3]));
            //水膜厚度
            road.setSmhd(Float.parseFloat(datas[4]));
            //冰厚度
            road.setBhd(Float.parseFloat(datas[5]));
            //雪厚度
            road.setXhd(Float.parseFloat(datas[6]));
            //地面温度
            road.setDmwd(Float.parseFloat(datas[7]));
        }
        else
        {
            road.setLmztdm(20);
        }
        return road;
    }
}
